#include "graph-node.h"
#include "order-item-addition-dialog.h"
#include "order-item-section-model.h"
#include "order-item-section-view.h"

OrderItemSectionView::OrderItemSectionView(QWidget *parent) :
    StandardSectionView(parent)
{
}

void OrderItemSectionView::initialize()
{
    m_sectionModel = new OrderItemSectionModel(this);
    m_addDataText = "Dodaj pozycję";
    m_editDataText = "Edytuj pozycję";
    m_removeDataText = "Usuń pozycję";
    m_removeDataConfirmation = "Czy na pewno chcesz usunąć zaznaczone pozycje?";
    StandardSectionView::initialize();
}

void OrderItemSectionView::addData()
{
    OrderItemAdditionDialog* dialog = new OrderItemAdditionDialog(this);
    connect (dialog, &OrderItemAdditionDialog::addDataRequested, m_sectionModel, &AbstractSectionModel::addData);
    dialog->setAttribute(Qt::WA_DeleteOnClose);
    dialog->setWindowTitle(m_addDataText);
    dialog->setSectionInfo(m_sectionNode->data());
    dialog->initialize();
    dialog->open();
}
